﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using ProgNetComponents.Design.Designers;
using System.Drawing.Design;

namespace ProgNetComponents.Data.Query
{
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class SelectData : ProgNetComponents.NamedObjects.INamedObject, ICloneable
    {
        private  SelectQueryCollection _SingleCollection = new SelectQueryCollection();
        private  SelectQueryCollection _MultiCollection = new SelectQueryCollection();

        public string Name
        {
            get;
            set;
        }
        
        [Browsable(false)]
        public DataManager SingleRecordManager
        {
            get;
            internal set;
        }

        [Browsable(false)]
        public DataManager MultiRecordManager
        {
            get;
            internal set;
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public SelectQueryCollection SingleRecordQueries
        {
            get
            {
                return _SingleCollection;
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public SelectQueryCollection MultiRecordQueries
        {
            get
            {
                return _MultiCollection;
            }
        }

        public override string ToString()
        {
            return Name;
        }

        #region ICloneable Members

        public object Clone()
        {
            SelectData i  = new SelectData();
            i.Name = this.Name;
            foreach (SelectQuery s in SingleRecordQueries)
                i.SingleRecordQueries.Add(s.Clone() as SelectQuery);

            foreach (SelectQuery s in MultiRecordQueries)
                i.MultiRecordQueries.Add(s.Clone() as SelectQuery);
            return i;
        }

        #endregion
    }

    [TypeConverter(typeof(ProgNetComponents.Design.TypeConverters.CollectionTypeConverter))]
    [Editor(typeof(Design.Editors.SelectDataCollectionEditor), typeof(UITypeEditor))]
    public class SelectDataCollection : ProgNetComponents.NamedObjects.NamedCollectionBase<SelectData>
    {
        
    }

    [ToolboxItem(true)]
    [Designer(typeof(SelectDataContainerDesigner))]
    public class SelectDataContainer : Component
    {
        private SelectDataCollection _Items = new SelectDataCollection();
        
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        
        public SelectDataCollection Items
        {
            get { return _Items; }
        }


    }
}
